﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="ControlStyle.xaml"></ResourceDictionary>
        </ResourceDictionary.MergedDictionaries>
        <Style x:Key="ListBoxStyle" TargetType="ListBox">
                <Setter Property="Width" Value="Auto"></Setter>
                <Setter Property="Height" Value="Auto"></Setter>
                <Setter Property="HorizontalAlignment" Value="Stretch"></Setter>
                <Setter Property="VerticalAlignment" Value="Top"></Setter>
                <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                <Setter Property="VerticalContentAlignment" Value="Top"></Setter>
                <Setter Property="Margin" Value="6"></Setter>
                <Setter Property="Foreground" Value="White"></Setter>
                <Setter Property="Background" Value="Transparent"></Setter>
                <Setter Property="BorderBrush" Value="{x:Null}"></Setter>
                <Setter Property="BorderThickness" Value="0"></Setter>
                <Setter Property="SelectionMode" Value="Single"></Setter>

                <!-- 设置ListBoxItem样式 -->
                <Setter Property="ItemContainerStyle">
                        <Setter.Value>

                                <Style TargetType="ListBoxItem">

                                        <!-- 设置控件模板 -->

                                        <Setter Property="Template">

                                                <Setter.Value>

                                                        <ControlTemplate TargetType="ListBoxItem">

                                                                <Border Name="ItemBorder"
                                                                        Background="{TemplateBinding Background}">

                                                                        <ContentPresenter
                                                                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                                                TextBlock.Foreground="{TemplateBinding Foreground}" />

                                                                </Border>

                                                        </ControlTemplate>

                                                </Setter.Value>

                                        </Setter>


                                        <!-- 设置触发器 -->

                                        <Style.Triggers>

                                                <Trigger Property="IsSelected" Value="true">
                                                        <Setter Property="Foreground" Value="Blue" />
                                                </Trigger>

                                                <Trigger Property="IsMouseOver" Value="true">
                                                        <Setter Property="Foreground" Value="Green" />
                                                </Trigger>

                                        </Style.Triggers>

                                </Style>

                        </Setter.Value>
                </Setter>


        </Style>


</ResourceDictionary>